package com.caishi.lkx.user.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.zzw.common.entity.impl.BSIntEntity;
import com.zzw.common.service.model.RouterServiceModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * @author by keray
 * date:2021/4/20 10:24 上午
 */
@Getter
@Setter
public class ISysUserLog<T extends ISysUserLog<T>> extends BSIntEntity<T> {
    public static final String ADMIN_LOGIN = "admin_login";
    public static final String TEACHER_LOGIN = "teacher_login";
    public static final String MEMBER_LOGIN = "user_login";
    public static final String GROUP_MEMBER_LOGIN = "group_admin_login";
    public static final String GROUP_ADMIN_LOGIN = "group_member_login";
    public static final String AGENT_LOGIN = "agent_login";


    private LocalDateTime createdTime;
    private String userId;
    private String logType;
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Object content;

    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log")
    public static class SysUserLog extends ISysUserLog<SysUserLog> implements RouterServiceModel {

    }


    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_admin_login")
    public static class SysUserLogAdminLogin extends ISysUserLog<SysUserLogAdminLogin> {
        @TableField(exist = false)
        private String logType = ADMIN_LOGIN;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_teacher_login")
    public static class SysUserLogTeacherLogin extends ISysUserLog<SysUserLogTeacherLogin> {
        @TableField(exist = false)
        private String logType = TEACHER_LOGIN;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_member_login")
    public static class SysUserLogMemberLogin extends ISysUserLog<SysUserLogMemberLogin> {
        @TableField(exist = false)
        private String logType = MEMBER_LOGIN;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_group_admin_login")
    public static class SysUserLogGroupAdminLogin extends ISysUserLog<SysUserLogGroupAdminLogin> {
        @TableField(exist = false)
        private String logType = GROUP_ADMIN_LOGIN;
    }


    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_group_member_login")
    public static class SysUserLogGroupMemberLogin extends ISysUserLog<SysUserLogGroupMemberLogin> {
        @TableField(exist = false)
        private String logType = GROUP_MEMBER_LOGIN;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    @TableName("sys_user_log_agent_login")
    public static class SysUserLogAgentLogin extends ISysUserLog<SysUserLogAgentLogin> {
        @TableField(exist = false)
        private String logType = AGENT_LOGIN;
    }
}
